﻿Public MustInherit Class NodeVm
    Inherits ViewModelBase

    Public Property ObjectTree As ObjectTree

    Public Sub New(objectTree As ObjectTree)
        Me.ObjectTree = objectTree
    End Sub

    Private mIsExpanded As Boolean
    Public Property IsExpanded As Boolean
        Get
            Return mIsExpanded
        End Get
        Set(value As Boolean)
            If mIsExpanded <> value Then
                mIsExpanded = value
                OnExpanded()
                RaisePropertyChanged("IsExpanded")
            End If
        End Set
    End Property

    Private mIsSelected As Boolean
    Public Property IsSelected As Boolean
        Get
            Return mIsSelected
        End Get
        Set(value As Boolean)
            If mIsSelected <> value Then
                mIsSelected = value
                OnIsSelected()
                RaisePropertyChanged("IsSelected")
            End If
        End Set
    End Property

    Protected Overridable Sub OnIsSelected()
        ObjectTree.SelectedNode = Me
    End Sub

    Protected Overridable Sub OnExpanded()

    End Sub

    Public Function BuildContextMenu() As List(Of MenuInfo)
        Dim list As New List(Of MenuInfo)
        BuildContextMenuInternal(list)
        Return list
    End Function

    Protected Overridable Sub BuildContextMenuInternal(list As List(Of MenuInfo))

    End Sub

    Public Property ObjectType As ObjectType
    Public Property ObjectSubType As ObjectSubType
End Class
